<template>
  <div class="feedback-wrap">
      <div class="title">意见反馈</div>
      <x-textarea :show-counter="false" :max="300" placeholder="请填写您的反馈意见(300字内）" v-model="contents"></x-textarea>
      <div class="title">请留下您的邮箱，以便给您回复</div>
      <input :max="40" v-model="email"  placeholder="请输入您的邮箱" type="email">
      <div class="btn" @click="submut">提交</div>
  </div>
</template>

<script>
import { XTextarea } from 'vux'
let CONSTANT = require('../../../wechat/static/constant/constant.js'),
    common = require("../../../wechat/static/common/common.js"),
    wsService = require("../../../wechat/static/common/wechat-jsdk.js");
export default {
  components: {
      XTextarea
  },
  data () {
    return {
        email:'',
        contents:''
    }
  },
  mounted(){
     console.log(location)
     console.log(location.search)
  },
  methods:{
      submut(){
        var reg = /^((([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6}\;))*(([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})))$/;
        if (!this.contents) {
            this.$vux.toast.show({
                text: '意见不能为空',
                type:'cancel'
            })
            return;
        }
        if (!this.email) {
            this.$vux.toast.show({
                text: '邮箱不能为空',
                type:'cancel'
            })
            return;
        }
        if (!reg.test(this.email)) {
            this.$vux.toast.show({
                text: '邮箱格式不对',
                type:'cancel'
            })
            return;
        }
        let  url = CONSTANT.URL.ACTIVITY.SAVEADVICE,
            param = {
                email:this.email,
                contents:this.contents
            }
        common.requestAjax(url,param,{},(res)=>{
            if(res.status == 200){
                 this.$vux.toast.show({
                    text: res.msg
                })
                this.$router.replace('/me');
            }else{
              this.$vux.toast.show({
                    text:res.msg,
                    type:'cancel'
                })
            }
        })       
      }
  },
}
</script>

<style lang="scss">
 .feedback-wrap{
     height: 100%;
     background-color: #f4f4f4;
     font-size: .3rem;
     color: #333;
     padding: .3rem;
     .weui-cell{
         padding: 0;
     }
     .vux-x-textarea.weui-cell::before{
         border: 0; 
     }
     textarea{
         width: 6.48rem;
         height: 2.88rem;
         margin: .21rem 0 .25rem;
         border-radius: 4px;
         -webkit-border-radius: 4px;
         border: 0px;
         padding: .21rem 
     }
     input{
         width: 6.48rem;
         height: .88rem;
         border-radius: 4px;
         -webkit-border-radius: 4px;
         border: 0px;
         padding: 0 .21rem;
         margin-top: .21rem;
         font-size: .3rem;
         &:focus{
             outline: 0px;
         }
     }
     .btn{
         width: 6.9rem;
         height: .88rem;
         text-align: center;
         line-height: .88rem;
         background-color: #0063AE;
         font-size: .34rem;
         color: #fff;
         border-radius: 4px;
         -webkit-border-radius: 4px;
         margin-top: 2.77rem;
     }
 }
</style>
